#pragma once

#include <QObject>
#include <QMessageBox>
#include <QDebug>

#include <wrl/client.h>
#include <Windows.h>

#include <cstdint>
#include <cassert>
#include <cstdlib>
#include <cwchar>
#include <cstddef>
#include <atomic>
#include <thread>
#include <new>
#include <string>
#include <sstream>

#include <dxgi1_4.h>
#include <D3D11.h>
#include <d2d1_1.h>
#include <d2d1_1helper.h>
#include <dwrite_2.h>
#include <wincodec.h>

#include <experimental/resumable>
#include <filesystem>

#pragma comment(lib, "dxgi.lib")
#pragma comment(lib, "d3d11.lib")
#pragma comment(lib, "dwrite.lib" )
#pragma comment(lib, "d3dcompiler.lib")
#pragma comment(lib, "d2d1.lib" )
#pragma comment(lib, "windowscodecs.lib" )

#pragma comment(lib, "dxguid.lib")
#pragma comment(lib, "Winmm.lib")

// 添加所有要引用的库
#pragma comment(lib, "d3d11.lib")
#pragma comment(lib, "dxgi.lib")
#pragma comment(lib, "dxguid.lib")
#pragma comment(lib, "D3DCompiler.lib")
#pragma comment(lib, "winmm.lib")

using namespace std::experimental;
//using namespace DirectX;
//using namespace std::filesystem;

#ifndef HR
#define HR(x)												\
	{															\
		HRESULT tmphr = (x);										\
		if(FAILED(tmphr))											\
		{														\
			QMessageBox::critical(this, "critical", QString("file[%1]line[%2]").arg(__FILEW__).arg(__LINE__));\
		}														\
	}
#endif

// 安全COM组件释放宏
#define SAFE_RELEASE(p) { if ((p)) { (p)->Release(); (p) = nullptr; } }

// 使用模板别名(C++11)简化类型名
template <class T>
using ComPtr = Microsoft::WRL::ComPtr<T>;

// 计算数组大小
#define lengthof(a) (sizeof(a)/sizeof(*(a)))
